package com.anji.hyperneat.nd;

import java.io.IOException;
import java.io.InputStream;

import com.anji.hyperneat.nd.NDActivatorArray.ActivatorArrayIterator;
import com.anji.hyperneat.onlinereinforcement.ActivatorNDABCHebbian;
import com.anji.hyperneat.onlinereinforcement.ActivatorNDBackPropagator;
import com.anji.hyperneat.onlinereinforcement.ActivatorNDHebbian;
import com.anji.hyperneat.onlinereinforcement.ActivatorNDTemporalDifference;
import com.anji.hyperneat.onlinereinforcement.GridNetHebbianABC;
import com.anji.hyperneat.onlinereinforcement.GridNetNDLR;
import com.anji.hyperneat.onlinereinforcement.GridNetTD;
import com.anji.hyperneat.onlinereinforcement.OnlineLearningNetType;
import com.anji.hyperneat.onlinereinforcement.RotationalBackPropActivator3d;
import com.anji.util.Properties;

public class Util {
	/**
	 * 
	 * @param coords
	 * @return
	 */
	public static int[] getTgtCoordsFromCoordsSet(int[] coords) {
		int[] tgt = new int[coords.length/2];
		for (int i = 0; i < tgt.length; i++) tgt[i] = coords[i];
		return tgt;
	}
	
	/**
	 * 
	 * @param coords
	 * @return
	 */
	public static int[] getSrcCoordsFromCoordsSet(int[] coords) {
		int offset = coords.length/2;
		int[] src = new int[offset];
		for (int i = offset; i < coords.length; i++) 
			src[i-offset] = coords[i];
		return src;
	}
	
	/**
	 * Returns a subset of a given set of coordaintes from startIdx thru (including) endIdx.
	 * Does not perform bounds checking.
	 * @param coords
	 * @param startIdx Index of first coordinate to copy
	 * @param endIdx The index of the last coordinate to copy
	 * @return
	 */
	public static int[] getCoordSubset(int[] coords, int startIdx, int endIdx) {
		int[] newCoords = new int[endIdx - startIdx + 1];
		for (int i = startIdx; i <= endIdx; i++) 
			newCoords[i-startIdx] = coords[i];
		return newCoords;
	}

	public static int[] joinCoords(int[]... coords) {
		int a = 0;
		for (int[] set : coords) a += set.length;
		int[] newCoords = new int[a];
		
		a = 0;
		for (int[] set : coords) {
			for (int b : set) {
				newCoords[a++] = b;
			}
		}
		return newCoords;
	}
		
	public static void main(String[] args) throws IOException {
		
		Properties p = new Properties("properties/or2.properties");
		InputStream in = ClassLoader.getSystemResourceAsStream( "properties/check.properties" );
		p.load(in);
		
	}
}
